unit uMain;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, IfxMonitor, StdCtrls, IfxConnection, IfxFileMonitor,
  IfxVisualMonitor, Menus, ComCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox4: TCheckBox;
    EditLinesCount: TEdit;
    UpDown1: TUpDown;
    CheckBox5: TCheckBox;
    ButtonClear: TButton;
    GroupBox1: TGroupBox;
    ChkFilterInformation: TCheckBox;
    ChkFilterWarning: TCheckBox;
    ChkFilterError: TCheckBox;
    CompositMonitor: TIfxCompositMonitor;
    VisualMonitor: TIfxVisualMonitor;
    FileMonitor: TIfxFileMonitor;
    procedure Button1Click(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
    procedure CheckBox4Click(Sender: TObject);
    procedure CheckBox5Click(Sender: TObject);
    procedure ButtonClearClick(Sender: TObject);
    procedure ChkFilterClick(Sender: TObject);
  private
    function EmulateWarning : string;
    function EmulateInfo : string;
    function EmulateError : string;
    function EmulateVisualError : string;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

const
  EvType : array[1..3] of TIfxMonitorEventType = (meInformation, meWarning, meError);

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  CompositMonitor.HandleWarning('sample warning');
  CompositMonitor.HandleInformation('sample info msg');
  FileMonitor.HandleError('direct error simulation');

  CompositMonitor.HandleWarning(EmulateWarning);
  CompositMonitor.HandleInformation(EmulateInfo);
  CompositMonitor.HandleError(EmulateError);

  VisualMonitor.MaxCapacity := UpDown1.Position;
  //VisualMonitor.HandleError('test visual error');
  //VisualMonitor.HandleError(EmulateVisualError);
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  VisualMonitor.AlignRight := TCheckBox(sender).Checked;
end;

procedure TForm1.CheckBox2Click(Sender: TObject);
begin
  VisualMonitor.StayOnTop := TCheckBox(sender).Checked;
end;

procedure TForm1.CheckBox4Click(Sender: TObject);
begin
  VisualMonitor.Visible := TCheckBox(sender).Checked;
end;

procedure TForm1.CheckBox5Click(Sender: TObject);
begin
  VisualMonitor.TopBasedLog := TCheckBox(sender).Checked;
end;

function TForm1.EmulateError: string;
begin
  result := 'late sample error';
end;

function TForm1.EmulateInfo: string;
begin
  result := 'late sample info';
end;

function TForm1.EmulateVisualError: string;
begin                           
  result := 'late GUI error';
end;

function TForm1.EmulateWarning: string;
begin
  result := 'late sample warning';
end;

procedure TForm1.ButtonClearClick(Sender: TObject);
begin
  VisualMonitor.Clear;
end;

procedure TForm1.ChkFilterClick(Sender: TObject);
begin
  if TCheckBox(Sender).Checked then
    CompositMonitor.Filter := CompositMonitor.Filter + [EvType[TCheckBox(Sender).Tag]]
  else
    CompositMonitor.Filter := CompositMonitor.Filter - [EvType[TCheckBox(Sender).Tag]];
end;

end.
